//*****************************************************************************
//
//								SpeedoMeter.c
//
//*****************************************************************************
//
//
#include "Config.h"
#include "reg.h"
#include "typedefs.h"
#include "printf.h"
#include "util.h"
#include "CPU.h"
#include "I2C.h"
#include "OSD\dv_OSD.h"
#include "SPI.h"
//#include "SPI_Map.h"
#include "Global.h"
#include "OSD\md_OSD.h"
#include "SpeedoMeter.h"
#include "OSD\app_OSD.h"
#include "app_MSG.h"
//#include "OSD\User_handle.h"

#if 0

   // *********** Combined file information ***********
typedef struct { 
	DWORD start; 
	DWORD length; 
	WORD left; 
	WORD top; 
	WORD right; 
	WORD bottom; 
}SPIIMAGE; 




CONST ATTRIBUTE canvas0s_attr[]={
{0x01, 0x02, 0x00, 0, 0},// color alpha blending
{0x02, 0x00, 0x00, 0, 0},//color blinking
{0xff,0,0,0}
};


CONST ATTRIBUTE canvas1s_attr[]={
{0x01, 0x02, 0x00, 0, 0},// color alpha blending
{0x02, 0x00, 0x00, 0, 0},//color blinking
{0xff,0,0,0}
};


CONST ATTRIBUTE canvas2s_attr[]={
{0x01, 0x00, 0x00, 0, 0},
{0x02, 0x0, 0x00, 0, 0},//color blinking
{0xff,0,0,0}
};


CANVAS User_Canvasspeed[]={
    {0, 0, 0, 0, 0, 8, 800, 480, canvas0s_attr, 0},
    {800, 0, 0, 0, 1, 8, 800, 480, canvas1s_attr, 1},
    {0, 480, 0, 0, 2, 16, 800, 480, canvas2s_attr, 2},
};

//#define FLASH_DATA_START_ADDR 0x200000

 FAR CONST SPIIMAGE nneedlere[] = { 
	{ 0x000000, 0x000285, 37, 311,294, 329 },  // wnew0 
	{ 0x000285, 0x00079C, 37, 306,294, 328 },  // wnew1 
	{ 0x000A21, 0x000825, 37, 301,294, 328 },  // wnew2 
	{ 0x001246, 0x000835, 37, 296,294, 327 },  // wnew3 
	{ 0x001A7B, 0x00086F, 37, 291,294, 327 },  // wnew4 
	{ 0x0022EA, 0x000893, 38, 286,294, 326 },  // wnew5 
	{ 0x002B7D, 0x0008AE, 38, 281,294, 326 },  // wnew6 
	{ 0x00342B, 0x0008C4, 38, 277,295, 325 },  // wnew7 
	{ 0x003CEF, 0x0008E3, 39, 272,295, 325 },  // wnew8 
	{ 0x0045D2, 0x0008FC, 39, 267,295, 324 },  // wnew9 
	{ 0x004ECE, 0x00091C, 40, 262,295, 324 },  // wnew10 
	{ 0x0057EA, 0x00092B, 41, 257,295, 324 },  // wnew11 
	{ 0x006115, 0x00093D, 42, 253,296, 323 },  // wnew12 
	{ 0x006A52, 0x00094F, 42, 248,296, 323 },  // wnew13 
	{ 0x0073A1, 0x00096F, 43, 243,296, 322 },  // wnew14 
	{ 0x007D10, 0x000982, 44, 238,296, 322 },  // wnew15 
	{ 0x008692, 0x00099B, 46, 234,297, 321 },  // wnew16 
	{ 0x00902D, 0x0009A0, 47, 229,297, 321 },  // wnew17 
	{ 0x0099CD, 0x0009C3, 48, 225,297, 320 },  // wnew18 
	{ 0x00A390, 0x0009D9, 49, 220,297, 320 },  // wnew19 
	{ 0x00AD69, 0x0009EE, 51, 215,298, 319 },  // wnew20 
	{ 0x00B757, 0x0009FE, 52, 211,298, 319 },  // wnew21 
	{ 0x00C155, 0x000A0B, 54, 206,298, 318 },  // wnew22 
	{ 0x00CB60, 0x000A19, 56, 202,299, 318 },  // wnew23 
	{ 0x00D579, 0x000A31, 57, 197,299, 318 },  // wnew24 
	{ 0x00DFAA, 0x000A49, 59, 193,299, 317 },  // wnew25 
	{ 0x00E9F3, 0x000A57, 61, 189,299, 317 },  // wnew26 
	{ 0x00F44A, 0x000A6A, 63, 184,300, 316 },  // wnew27 
	{ 0x00FEB4, 0x000A7F, 65, 180,300, 316 },  // wnew28 
	{ 0x010933, 0x000A88, 68, 176,300, 315 },  // wnew29 
	{ 0x0113BB, 0x000A9F, 70, 172,301, 315 },  // wnew30 
	{ 0x011E5A, 0x000AB1, 72, 168,301, 314 },  // wnew31 
	{ 0x01290B, 0x000ABE, 74, 164,301, 314 },  // wnew32 
	{ 0x0133C9, 0x000ACF, 77, 159,302, 313 },  // wnew33 
	{ 0x013E98, 0x000AE0, 79, 155,302, 313 },  // wnew34 
	{ 0x014978, 0x000AED, 82, 152,303, 312 },  // wnew35 
	{ 0x015465, 0x000AFA, 85, 148,303, 312 },  // wnew36 
	{ 0x015F5F, 0x000B0F, 87, 144,303, 312 },  // wnew37 
	{ 0x016A6E, 0x000B18, 90, 140,304, 311 },  // wnew38 
	{ 0x017586, 0x000B26, 93, 136,304, 311 },  // wnew39 
	{ 0x0180AC, 0x000B36, 96, 133,304, 310 },  // wnew40 
	{ 0x018BE2, 0x000B43, 99, 129,305, 310 },  // wnew41 
	{ 0x019725, 0x000B4E, 102, 125,305, 309 },	// wnew42 
	{ 0x01A273, 0x000B58, 105, 122,306, 309 },	// wnew43 
	{ 0x01ADCB, 0x000B68, 109, 118,306, 308 },	// wnew44 
	{ 0x01B933, 0x000BAA, 112, 115,306, 308 },	// wnew45 
	{ 0x01C4DD, 0x000B8E, 115, 112,307, 308 },	// wnew46 
	{ 0x01D06B, 0x000B94, 119, 108,307, 307 },	// wnew47 
	{ 0x01DBFF, 0x000B97, 122, 105,308, 307 },	// wnew48 
	{ 0x01E796, 0x000BA9, 126, 102,308, 306 },	// wnew49 
	{ 0x01F33F, 0x000BC2, 129, 99,308, 306 },  // wnew50 
	{ 0x01FF01, 0x000BC9, 133, 96,309, 305 },  // wnew51 
	{ 0x020ACA, 0x000BD5, 137, 93,309, 305 },  // wnew52 
	{ 0x02169F, 0x000BD8, 140, 90,310, 305 },  // wnew53 
	{ 0x022277, 0x000BE3, 144, 87,310, 304 },  // wnew54 
	{ 0x022E5A, 0x000BE8, 148, 85,311, 304 },  // wnew55 
	{ 0x023A42, 0x000BF6, 152, 82,311, 303 },  // wnew56 
	{ 0x024638, 0x000C0B, 156, 79,311, 303 },  // wnew57 
	{ 0x025243, 0x000C09, 160, 77,312, 303 },  // wnew58 
	{ 0x025E4C, 0x000C1C, 164, 74,312, 302 },  // wnew59 
	{ 0x026A68, 0x000C1B, 168, 72,313, 302 },  // wnew60 
	{ 0x027683, 0x000C24, 172, 70,313, 302 },  // wnew61 
	{ 0x0282A7, 0x000C34, 176, 67,314, 301 },  // wnew62 
	{ 0x028EDB, 0x000C3E, 181, 65,314, 301 },  // wnew63 
	{ 0x029B19, 0x000C4A, 185, 63,315, 301 },  // wnew64 
	{ 0x02A763, 0x000C4C, 189, 61,315, 300 },  // wnew65 
	{ 0x02B3AF, 0x000C54, 193, 59,315, 300 },  // wnew66 
	{ 0x02C003, 0x000C54, 198, 57,316, 300 },  // wnew67 
	{ 0x02CC57, 0x000C5A, 202, 56,316, 299 },  // wnew68 
	{ 0x02D8B1, 0x000C66, 207, 54,317, 299 },  // wnew69 
	{ 0x02E517, 0x000C6B, 211, 52,317, 299 },  // wnew70 
	{ 0x02F182, 0x000C74, 216, 51,318, 298 },  // wnew71 
	{ 0x02FDF6, 0x000CA1, 220, 49,318, 298 },  // wnew72 
	{ 0x030A97, 0x000C7F, 225, 48,319, 298 },  // wnew73 
	{ 0x031716, 0x000C81, 230, 47,319, 297 },  // wnew74 
	{ 0x032397, 0x000C83, 234, 45,320, 297 },  // wnew75 
	{ 0x03301A, 0x000C8B, 239, 44,320, 297 },  // wnew76 
	{ 0x033CA5, 0x000C94, 244, 43,320, 297 },  // wnew77 
	{ 0x034939, 0x000C95, 248, 42,321, 296 },  // wnew78 
	{ 0x0355CE, 0x000C95, 253, 41,321, 296 },  // wnew79 
	{ 0x036263, 0x000C98, 258, 41,322, 296 },  // wnew80 
	{ 0x036EFB, 0x000C95, 263, 40,322, 295 },  // wnew81 
	{ 0x037B90, 0x000CA1, 267, 39,323, 295 },  // wnew82 
	{ 0x038831, 0x000C9A, 272, 39,323, 295 },  // wnew83 
	{ 0x0394CB, 0x000C98, 277, 38,324, 295 },  // wnew84 
	{ 0x03A163, 0x000CA1, 282, 38,324, 295 },  // wnew85 
	{ 0x03AE04, 0x000CA0, 287, 38,325, 294 },  // wnew86 
	{ 0x03BAA4, 0x000CA2, 291, 38,325, 294 },  // wnew87 
	{ 0x03C746, 0x000C9E, 296, 37,325, 294 },  // wnew88 
	{ 0x03D3E4, 0x000C9C, 301, 37,326, 294 },  // wnew89 
	{ 0x03E080, 0x000C9A, 306, 37,326, 294 },  // wnew90 
	{ 0x03ED1A, 0x000C9E, 309, 37,329, 294 },  // wnew91 
	{ 0x03F9B8, 0x000C9C, 309, 37,334, 294 },  // wnew92 
	{ 0x040654, 0x000C9D, 310, 37,339, 294 },  // wnew93 
	{ 0x0412F1, 0x000CA2, 310, 37,344, 294 },  // wnew94 
	{ 0x041F93, 0x000CA3, 310, 38,348, 294 },  // wnew95 
	{ 0x042C36, 0x000C99, 311, 38,353, 294 },  // wnew96 
	{ 0x0438CF, 0x000C9B, 311, 38,358, 295 },  // wnew97 
	{ 0x04456A, 0x000C9D, 312, 39,363, 295 },  // wnew98 
	{ 0x045207, 0x000C9C, 312, 39,368, 295 },  // wnew99 
	{ 0x045EA3, 0x000C95, 313, 40,373, 295 },  // wnew100 
	{ 0x046B38, 0x000C97, 313, 40,377, 295 },  // wnew101 
	{ 0x0477CF, 0x000C97, 314, 41,382, 296 },  // wnew102 
	{ 0x048466, 0x000C95, 314, 42,387, 296 },  // wnew103 
	{ 0x0490FB, 0x000C92, 315, 43,392, 296 },  // wnew104 
	{ 0x049D8D, 0x000C89, 315, 44,396, 296 },  // wnew105 
	{ 0x04AA16, 0x000C82, 316, 45,401, 297 },  // wnew106 
	{ 0x04B698, 0x000C85, 316, 46,406, 297 },  // wnew107 
	{ 0x04C31D, 0x000C7E, 316, 47,410, 297 },  // wnew108 
	{ 0x04CF9B, 0x000CA1, 317, 49,415, 297 },  // wnew109 
	{ 0x04DC3C, 0x000C70, 317, 50,419, 298 },  // wnew110 
	{ 0x04E8AC, 0x000C6E, 318, 52,424, 298 },  // wnew111 
	{ 0x04F51A, 0x000C68, 318, 53,428, 298 },  // wnew112 
	{ 0x050182, 0x000C5A, 319, 55,433, 298 },  // wnew113 
	{ 0x050DDC, 0x000C5B, 319, 57,437, 299 },  // wnew114 
	{ 0x051A37, 0x000C51, 320, 58,442, 299 },  // wnew115 
	{ 0x052688, 0x000C4F, 320, 60,446, 299 },  // wnew116 
	{ 0x0532D7, 0x000C51, 321, 62,450, 300 },  // wnew117 
	{ 0x053F28, 0x000C39, 321, 64,455, 300 },  // wnew118 
	{ 0x054B61, 0x000C35, 322, 66,459, 300 },  // wnew119 
	{ 0x055796, 0x000C27, 322, 69,463, 301 },  // wnew120 
	{ 0x0563BD, 0x000C1F, 322, 71,467, 301 },  // wnew121 
	{ 0x056FDC, 0x000C1C, 323, 73,471, 301 },  // wnew122 
	{ 0x057BF8, 0x000C09, 323, 76,475, 302 },  // wnew123 
	{ 0x058801, 0x000C05, 324, 78,480, 302 },  // wnew124 
	{ 0x059406, 0x000BFA, 324, 81,483, 302 },  // wnew125 
	{ 0x05A000, 0x000BED, 325, 83,487, 303 },  // wnew126 
	{ 0x05ABED, 0x000BE7, 325, 86,491, 303 },  // wnew127 
	{ 0x05B7D4, 0x000BDD, 326, 89,495, 303 },  // wnew128 
	{ 0x05C3B1, 0x000BD3, 326, 92,499, 304 },  // wnew129 
	{ 0x05CF84, 0x000BC4, 327, 95,503, 304 },  // wnew130 
	{ 0x05DB48, 0x000BBC, 327, 98,506, 305 },  // wnew131 
	{ 0x05E704, 0x000BB4, 327, 101,510, 305 },	// wnew132 
	{ 0x05F2B8, 0x000B9D, 328, 104,513, 305 },	// wnew133 
	{ 0x05FE55, 0x000B92, 328, 107,517, 306 },	// wnew134 
	{ 0x0609E7, 0x000B93, 329, 110,520, 306 },	// wnew135 
	{ 0x06157A, 0x000BBC, 329, 114,524, 307 },	// wnew136 
	{ 0x062136, 0x000B70, 330, 117,527, 307 },	// wnew137 
	{ 0x062CA6, 0x000B67, 330, 120,530, 307 },	// wnew138 
	{ 0x06380D, 0x000B51, 330, 124,533, 308 },	// wnew139 
	{ 0x06435E, 0x000B43, 331, 127,537, 308 },	// wnew140 
	{ 0x064EA1, 0x000B3A, 331, 131,540, 309 },	// wnew141 
	{ 0x0659DB, 0x000B28, 332, 135,543, 309 },	// wnew142 
	{ 0x066503, 0x000B18, 332, 138,545, 310 },	// wnew143 
	{ 0x06701B, 0x000B0C, 333, 142,548, 310 },	// wnew144 
	{ 0x067B27, 0x000AFD, 333, 146,551, 310 },	// wnew145 
	{ 0x068624, 0x000AEE, 333, 150,554, 311 },	// wnew146 
	{ 0x069112, 0x000AEC, 334, 154,556, 311 },	// wnew147 
	{ 0x069BFE, 0x000AD5, 334, 158,559, 312 },	// wnew148 
	{ 0x06A6D3, 0x000ABE, 334, 162,561, 312 },	// wnew149 
	{ 0x06B191, 0x000AB7, 335, 166,564, 313 },	// wnew150 
	{ 0x06BC48, 0x000AA1, 335, 170,566, 313 },	// wnew151 
	{ 0x06C6E9, 0x000A87, 336, 174,569, 313 },	// wnew152 
	{ 0x06D170, 0x000A7E, 336, 178,571, 314 },	// wnew153 
	{ 0x06DBEE, 0x000A69, 336, 183,573, 314 },	// wnew154 
	{ 0x06E657, 0x000A59, 337, 187,575, 315 },	// wnew155 
	{ 0x06F0B0, 0x000A4C, 337, 191,577, 315 },	// wnew156 
	{ 0x06FAFC, 0x000A35, 337, 196,579, 316 },	// wnew157 
	{ 0x070531, 0x000A23, 338, 200,581, 316 },	// wnew158 
	{ 0x070F54, 0x000A15, 338, 205,582, 317 },	// wnew159 
	{ 0x071969, 0x0009FF, 338, 209,584, 317 },	// wnew160 
	{ 0x072368, 0x0009F1, 339, 213,585, 318 },	// wnew161 
	{ 0x072D59, 0x0009DB, 339, 218,587, 318 },	// wnew162 
	{ 0x073734, 0x0009C8, 339, 223,588, 318 },	// wnew163 
	{ 0x0740FC, 0x0009A8, 340, 227,590, 319 },	// wnew164 
	{ 0x074AA4, 0x00099B, 340, 232,591, 319 },	// wnew165 
	{ 0x07543F, 0x000986, 340, 237,592, 320 },	// wnew166 
	{ 0x075DC5, 0x000977, 340, 241,593, 320 },	// wnew167 
	{ 0x07673C, 0x00095F, 341, 246,594, 321 },	// wnew168 
	{ 0x07709B, 0x00093E, 341, 251,595, 321 },	// wnew169 
	{ 0x0779D9, 0x00093E, 341, 255,596, 322 },	// wnew170 
	{ 0x078317, 0x000919, 341, 260,597, 322 },	// wnew171 
	{ 0x078C30, 0x000904, 342, 265,597, 323 },	// wnew172 
	{ 0x079534, 0x0008E1, 342, 270,598, 323 },	// wnew173 
	{ 0x079E15, 0x0008CD, 342, 275,598, 323 },	// wnew174 
	{ 0x07A6E2, 0x0008BC, 342, 279,599, 324 },	// wnew175 
	{ 0x07AF9E, 0x00088E, 343, 284,599, 324 },	// wnew176 
	{ 0x07B82C, 0x000871, 343, 289,599, 325 },	// wnew177 
	{ 0x07C09D, 0x000857, 343, 294,600, 325 },	// wnew178 
	{ 0x07C8F4, 0x000827, 343, 299,600, 326 },	// wnew179 
	{ 0x07D11B, 0x0007C0, 343, 304,600, 326 },	// wnew180 

};

 #if 0
 CONST PALETTEENTRY palette_Speed[] = {
	 
		 0x01,0x00,0x02,0x7f,0x0a,0x00,0x02,0x7f,0x00,0x08,0x03,0x7f,0x0b,0x09,0x03,0x7f,
		 0x03,0x02,0x09,0x7f,0x0a,0x01,0x0a,0x7f,0x02,0x09,0x0a,0x7f,0x0b,0x09,0x0b,0x7f,
		 0x13,0x00,0x01,0x7f,0x1b,0x00,0x00,0x7f,0x13,0x09,0x04,0x7f,0x12,0x01,0x0b,0x7f,
		 0x1a,0x02,0x0a,0x7f,0x13,0x09,0x09,0x7f,0x1e,0x09,0x0e,0x7f,0x00,0x10,0x00,0x7f,
		 0x04,0x03,0x11,0x7f,0x0b,0x01,0x10,0x7f,0x0c,0x0a,0x12,0x00,0x12,0x02,0x12,0x7f,
		 0x1f,0x05,0x10,0x00,0x15,0x0b,0x13,0x00,0x1f,0x0c,0x10,0x00,0x23,0x00,0x00,0x7f,
		 0x2b,0x00,0x00,0x00,0x24,0x08,0x02,0x00,0x2c,0x0a,0x00,0x00,0x26,0x08,0x08,0x7f,
		 0x33,0x00,0x00,0x00,0x3b,0x00,0x00,0x00,0x31,0x09,0x00,0x7f,0x3b,0x0b,0x01,0x00,
		 0x35,0x0c,0x08,0x00,0x3a,0x0c,0x0c,0x00,0x3e,0x10,0x01,0x00,0x43,0x01,0x00,0x00,
		 0x4b,0x00,0x00,0x00,0x43,0x0a,0x02,0x00,0x4c,0x0a,0x02,0x00,0x4d,0x05,0x09,0x00,
		 0x47,0x0b,0x08,0x00,0x49,0x0b,0x0c,0x00,0x54,0x00,0x00,0x00,0x5a,0x01,0x00,0x00,
		 0x55,0x0b,0x02,0x00,0x5c,0x0a,0x03,0x00,0x53,0x06,0x0a,0x00,0x5b,0x05,0x09,0x00,
		 0x55,0x0a,0x0a,0x00,0x5a,0x0c,0x09,0x00,0x58,0x11,0x08,0x00,0x58,0x0d,0x11,0x00,
		 0x4a,0x1a,0x11,0x00,0x5c,0x12,0x13,0x00,0x63,0x02,0x01,0x00,0x6a,0x02,0x01,0x00,
		 0x65,0x09,0x02,0x00,0x6b,0x0b,0x03,0x00,0x60,0x0a,0x09,0x00,0x6b,0x0b,0x0b,0x00,
		 0x73,0x02,0x02,0x00,0x7b,0x02,0x03,0x00,0x74,0x0c,0x01,0x00,0x7b,0x0b,0x03,0x00,
		 0x7e,0x05,0x09,0x00,0x7b,0x0d,0x0b,0x00,0x68,0x14,0x0b,0x00,0x75,0x15,0x0b,0x00,
		 0x7a,0x0f,0x10,0x00,0x69,0x19,0x16,0x00,0x73,0x15,0x12,0x00,0x7c,0x14,0x13,0x00,
		 0x73,0x1d,0x13,0x00,0x7f,0x18,0x11,0x00,0x70,0x17,0x19,0x00,0x7a,0x17,0x1a,0x00,
		 0x76,0x1b,0x1a,0x00,0x7c,0x1b,0x1b,0x00,0x40,0x20,0x00,0x7f,0x5c,0x22,0x18,0x00,
		 0x60,0x20,0x00,0x7f,0x68,0x22,0x18,0x00,0x79,0x21,0x17,0x00,0x69,0x21,0x22,0x00,
		 0x72,0x20,0x24,0x00,0x7b,0x2b,0x20,0x00,0x77,0x25,0x2b,0x00,0x79,0x35,0x28,0x00,
		 0x80,0x00,0x00,0x7f,0x8c,0x02,0x04,0x00,0x83,0x0b,0x03,0x00,0x8d,0x0b,0x05,0x00,
		 0x89,0x06,0x0b,0x00,0x83,0x0c,0x0c,0x00,0x88,0x0a,0x0c,0x00,0x96,0x06,0x06,0x00,
		 0x88,0x16,0x0c,0x00,0x92,0x12,0x07,0x00,0x9c,0x10,0x03,0x00,0x92,0x12,0x0d,0x00,
		 0x9c,0x12,0x0a,0x00,0x95,0x19,0x0b,0x00,0x9a,0x18,0x0c,0x00,0x92,0x0b,0x14,0x00,
		 0x9e,0x09,0x11,0x00,0x83,0x15,0x12,0x00,0x8e,0x15,0x13,0x00,0x83,0x1c,0x15,0x00,
		 0x8b,0x1a,0x14,0x00,0x84,0x1a,0x1c,0x00,0x8c,0x1a,0x1b,0x00,0x94,0x13,0x12,0x00,
		 0x9d,0x14,0x13,0x00,0x94,0x1b,0x14,0x00,0x9c,0x1a,0x14,0x00,0x94,0x13,0x18,0x00,
		 0x9a,0x14,0x1a,0x00,0x94,0x1b,0x1b,0x00,0x9a,0x1e,0x1c,0x00,0xa6,0x08,0x0a,0x00,
		 0xb8,0x09,0x0a,0x00,0xa6,0x12,0x09,0x00,0xb9,0x14,0x0c,0x00,0xa3,0x07,0x12,0x00,
		 0xa2,0x0c,0x14,0x00,0xab,0x0c,0x12,0x00,0xb8,0x0c,0x12,0x00,0xa7,0x16,0x15,0x00,
		 0xb2,0x13,0x14,0x00,0xba,0x16,0x15,0x00,0xb2,0x1b,0x14,0x00,0xbc,0x18,0x16,0x00,
		 0xb3,0x14,0x19,0x00,0xbb,0x14,0x1b,0x00,0xb2,0x1a,0x1b,0x00,0xba,0x1b,0x1a,0x00,
		 0x80,0x20,0x00,0x7f,0x9c,0x21,0x0f,0x00,0x85,0x24,0x18,0x7f,0x97,0x22,0x1a,0x00,
		 0xa0,0x20,0x00,0x00,0xb9,0x20,0x0e,0x00,0xa6,0x22,0x1d,0x00,0xb7,0x24,0x1a,0x00,
		 0xa1,0x30,0x1e,0x00,0x8d,0x1f,0x20,0x7f,0xa9,0x1b,0x22,0x00,0xb5,0x1a,0x23,0x00,
		 0x8b,0x28,0x24,0x00,0x9c,0x24,0x22,0x00,0x9b,0x29,0x24,0x00,0x94,0x20,0x29,0x00,
		 0x98,0x2b,0x2c,0x00,0x8d,0x29,0x31,0x00,0xa6,0x23,0x22,0x00,0xa9,0x22,0x23,0x00,
		 0xa2,0x2d,0x23,0x00,0xa9,0x2b,0x23,0x00,0xa4,0x23,0x29,0x00,0xad,0x26,0x2c,0x00,
		 0xa4,0x2c,0x2d,0x00,0xaa,0x2f,0x28,0x00,0xb4,0x22,0x24,0x00,0xbc,0x23,0x23,0x00,
		 0xb3,0x29,0x27,0x00,0xbd,0x2f,0x23,0x00,0xb4,0x27,0x2f,0x00,0xbe,0x21,0x2a,0x00,
		 0xb2,0x28,0x2d,0x00,0xbb,0x2c,0x2b,0x00,0xab,0x30,0x20,0x00,0xb7,0x37,0x2e,0x00,
		 0xa9,0x2c,0x31,0x00,0xb4,0x2a,0x33,0x00,0xb1,0x3d,0x30,0x00,0xc6,0x0b,0x0a,0x00,
		 0xda,0x0b,0x0b,0x00,0xc7,0x13,0x0b,0x00,0xd8,0x13,0x0b,0x00,0xc6,0x0c,0x13,0x00,
		 0xcb,0x0d,0x12,0x00,0xd8,0x0c,0x13,0x00,0xc4,0x13,0x14,0x00,0xcc,0x13,0x13,0x00,
		 0xc5,0x1a,0x13,0x00,0xcc,0x1a,0x12,0x00,0xc2,0x14,0x19,0x00,0xcb,0x14,0x19,0x00,
		 0xc3,0x1b,0x1a,0x00,0xcc,0x1a,0x1b,0x00,0xd3,0x13,0x13,0x00,0xdb,0x13,0x12,0x00,
		 0xd3,0x1a,0x12,0x00,0xda,0x19,0x14,0x00,0xd2,0x14,0x1a,0x00,0xdb,0x13,0x1b,0x00,
		 0xd3,0x19,0x1b,0x00,0xdc,0x1a,0x1c,0x00,0xe4,0x04,0x02,0x00,0xec,0x04,0x03,0x00,
		 0xe4,0x0c,0x04,0x00,0xec,0x0a,0x04,0x00,0xe4,0x04,0x0a,0x00,0xec,0x05,0x0a,0x00,
		 0xe3,0x0c,0x0b,0x00,0xeb,0x0b,0x0b,0x00,0xfb,0x02,0x02,0x00,0xe5,0x11,0x0c,0x00,
		 0xf4,0x11,0x0c,0x00,0xe2,0x03,0x16,0x00,0xec,0x06,0x10,0x00,0xe3,0x0c,0x12,0x00,
		 0xeb,0x0b,0x12,0x00,0xec,0x05,0x19,0x00,0xe5,0x0f,0x19,0x00,0xec,0x0c,0x1b,0x00,
		 0xf6,0x06,0x12,0x00,0xe2,0x13,0x13,0x00,0xe9,0x12,0x12,0x00,0xe1,0x18,0x12,0x00,
		 0xe9,0x18,0x14,0x00,0xe3,0x13,0x1a,0x00,0xe9,0x12,0x19,0x00,0xe4,0x1a,0x1c,0x00,
		 0xe8,0x18,0x18,0x00,0xf3,0x12,0x14,0x00,0xc0,0x20,0x00,0x00,0xc6,0x23,0x1a,0x00,
		 0xd5,0x22,0x1c,0x00,0xc3,0x32,0x1f,0x00,0xe0,0x20,0x00,0x00,0xc3,0x17,0x23,0x00,
		 0xcc,0x14,0x22,0x00,0xc2,0x1c,0x23,0x00,0xca,0x1b,0x20,0x00,0xc6,0x1e,0x28,0x00,
		 0xd6,0x17,0x26,0x00,0xdb,0x13,0x25,0x00,0xd5,0x1c,0x21,0x00,0xdb,0x1a,0x20,0x00,
		 0xe5,0x15,0x22,0x00,0xeb,0x14,0x21,0x00,0xe1,0x1d,0x21,0x00,0xeb,0x1d,0x21,0x00,
		 0xc7,0x25,0x25,0x00,0xd5,0x23,0x25,0x00,0xc4,0x33,0x2e,0x00,0xca,0x2d,0x34,0x00,
		 0xc2,0x32,0x31,0x00,0xd5,0x31,0x32,0x00,0x80,0x20,0x40,0x00,0xa0,0x20,0x40,0x7f,
		 0xe0,0x00,0x40,0x00,0xc0,0x20,0x40,0x7f,0xe0,0x20,0x40,0x00,0xc0,0x40,0x40,0x00,
	 };
#endif
 
 
#if 0
#define FLASH_DATA_START_ADDR 0x300000
CONST BITMAP SystemIcon3[]={
    {550,300,8,0,0,0,0x8a,2162,0,(FLASH_DATA_START_ADDR+0x717)},/* Needlesmall_180_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,2327,1,(FLASH_DATA_START_ADDR+0xf89)},/* Needlesmall_182_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,2542,2,(FLASH_DATA_START_ADDR+0x18a1)},/* Needlesmall_184_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,2817,3,(FLASH_DATA_START_ADDR+0x228f)},/* Needlesmall_186_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,2970,4,(FLASH_DATA_START_ADDR+0x2d91)},/* Needlesmall_188_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,3135,5,(FLASH_DATA_START_ADDR+0x392b)},/* Needlesmall_190_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,3342,6,(FLASH_DATA_START_ADDR+0x456b)},/* Needlesmall_192_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,3496,7,(FLASH_DATA_START_ADDR+0x5279)},/* Needlesmall_194_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,3605,8,(FLASH_DATA_START_ADDR+0x6021)},/* Needlesmall_196_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,3713,9,(FLASH_DATA_START_ADDR+0x6e37)},/* Needlesmall_198_c_g1.bmp */
    {550,300,8,0,0,0,0x89,8684,10,(FLASH_DATA_START_ADDR+0x7cb9)},/* Needlesmall_200_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,3918,11,(FLASH_DATA_START_ADDR+0x9ea5)},/* Needlesmall_202_c_g1.bmp */
    {550,300,8,0,0,0,0x89,8764,12,(FLASH_DATA_START_ADDR+0xadf3)},/* Needlesmall_204_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9153,13,(FLASH_DATA_START_ADDR+0xd02f)},/* Needlesmall_206_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9222,14,(FLASH_DATA_START_ADDR+0xf3f1)},/* Needlesmall_208_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9081,15,(FLASH_DATA_START_ADDR+0x117f7)},/* Needlesmall_210_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9400,16,(FLASH_DATA_START_ADDR+0x13b71)},/* Needlesmall_212_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9061,17,(FLASH_DATA_START_ADDR+0x16029)},/* Needlesmall_214_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9572,18,(FLASH_DATA_START_ADDR+0x1838f)},/* Needlesmall_216_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9385,19,(FLASH_DATA_START_ADDR+0x1a8f3)},/* Needlesmall_218_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9568,20,(FLASH_DATA_START_ADDR+0x1cd9d)},/* Needlesmall_220_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9412,21,(FLASH_DATA_START_ADDR+0x1f2fd)},/* Needlesmall_222_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9996,22,(FLASH_DATA_START_ADDR+0x217c1)},/* Needlesmall_224_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9612,23,(FLASH_DATA_START_ADDR+0x23ecd)},/* Needlesmall_226_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9639,24,(FLASH_DATA_START_ADDR+0x26459)},/* Needlesmall_228_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9672,25,(FLASH_DATA_START_ADDR+0x28a01)},/* Needlesmall_230_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9666,26,(FLASH_DATA_START_ADDR+0x2afc9)},/* Needlesmall_232_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9877,27,(FLASH_DATA_START_ADDR+0x2d58b)},/* Needlesmall_234_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9748,28,(FLASH_DATA_START_ADDR+0x2fc21)},/* Needlesmall_236_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9827,29,(FLASH_DATA_START_ADDR+0x32235)},/* Needlesmall_238_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9802,30,(FLASH_DATA_START_ADDR+0x34899)},/* Needlesmall_240_c_g1.bmp */
    {550,300,8,0,0,0,0x89,10159,31,(FLASH_DATA_START_ADDR+0x36ee3)},/* Needlesmall_242_c_g1.bmp */
    {550,300,8,0,0,0,0x89,10117,32,(FLASH_DATA_START_ADDR+0x39693)},/* Needlesmall_244_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9901,33,(FLASH_DATA_START_ADDR+0x3be19)},/* Needlesmall_246_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9769,34,(FLASH_DATA_START_ADDR+0x3e4c7)},/* Needlesmall_248_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9837,35,(FLASH_DATA_START_ADDR+0x40af1)},/* Needlesmall_250_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9594,36,(FLASH_DATA_START_ADDR+0x4315f)},/* Needlesmall_252_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9774,37,(FLASH_DATA_START_ADDR+0x456d9)},/* Needlesmall_254_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9596,38,(FLASH_DATA_START_ADDR+0x47d07)},/* Needlesmall_256_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9797,39,(FLASH_DATA_START_ADDR+0x4a283)},/* Needlesmall_258_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9481,40,(FLASH_DATA_START_ADDR+0x4c8c9)},/* Needlesmall_260_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9366,41,(FLASH_DATA_START_ADDR+0x4edd3)},/* Needlesmall_262_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9428,42,(FLASH_DATA_START_ADDR+0x51269)},/* Needlesmall_264_c_g1.bmp */
    {550,300,8,0,0,0,0x89,8852,43,(FLASH_DATA_START_ADDR+0x5373d)},/* Needlesmall_266_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9998,44,(FLASH_DATA_START_ADDR+0x559d1)},/* Needlesmall_268_c_g1.bmp */
    {550,300,8,0,0,0,0x89,7751,45,(FLASH_DATA_START_ADDR+0x580df)},/* Needlesmall_270_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9143,46,(FLASH_DATA_START_ADDR+0x59f27)},/* Needlesmall_272_c_g1.bmp */
    {550,300,8,0,0,0,0x89,8773,47,(FLASH_DATA_START_ADDR+0x5c2df)},/* Needlesmall_274_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9340,48,(FLASH_DATA_START_ADDR+0x5e525)},/* Needlesmall_276_c_g1.bmp */
    {550,300,8,0,0,0,0x89,8938,49,(FLASH_DATA_START_ADDR+0x609a1)},/* Needlesmall_278_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9353,50,(FLASH_DATA_START_ADDR+0x62c8b)},/* Needlesmall_280_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9284,51,(FLASH_DATA_START_ADDR+0x65115)},/* Needlesmall_282_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9307,52,(FLASH_DATA_START_ADDR+0x67559)},/* Needlesmall_284_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9500,53,(FLASH_DATA_START_ADDR+0x699b5)},/* Needlesmall_286_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9366,54,(FLASH_DATA_START_ADDR+0x6bed1)},/* Needlesmall_288_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9697,55,(FLASH_DATA_START_ADDR+0x6e367)},/* Needlesmall_290_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9564,56,(FLASH_DATA_START_ADDR+0x70949)},/* Needlesmall_292_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9799,57,(FLASH_DATA_START_ADDR+0x72ea5)},/* Needlesmall_294_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9462,58,(FLASH_DATA_START_ADDR+0x754ed)},/* Needlesmall_296_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9538,59,(FLASH_DATA_START_ADDR+0x779e3)},/* Needlesmall_298_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9629,60,(FLASH_DATA_START_ADDR+0x79f25)},/* Needlesmall_300_c_g1.bmp */
    {550,300,8,0,0,0,0x89,10100,61,(FLASH_DATA_START_ADDR+0x7c4c3)},/* Needlesmall_302_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9765,62,(FLASH_DATA_START_ADDR+0x7ec37)},/* Needlesmall_304_c_g1.bmp */
    {550,300,8,0,0,0,0x89,10069,63,(FLASH_DATA_START_ADDR+0x8125d)},/* Needlesmall_306_c_g1.bmp */
    {550,300,8,0,0,0,0x89,10015,64,(FLASH_DATA_START_ADDR+0x839b3)},/* Needlesmall_308_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9683,65,(FLASH_DATA_START_ADDR+0x860d3)},/* Needlesmall_310_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9492,66,(FLASH_DATA_START_ADDR+0x886a7)},/* Needlesmall_312_c_g1.bmp */
    {550,300,8,0,0,0,0x89,10538,67,(FLASH_DATA_START_ADDR+0x8abbb)},/* Needlesmall_314_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9028,68,(FLASH_DATA_START_ADDR+0x8d4e5)},/* Needlesmall_316_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9638,69,(FLASH_DATA_START_ADDR+0x8f829)},/* Needlesmall_318_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9363,70,(FLASH_DATA_START_ADDR+0x91dcf)},/* Needlesmall_320_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9496,71,(FLASH_DATA_START_ADDR+0x94263)},/* Needlesmall_322_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9474,72,(FLASH_DATA_START_ADDR+0x9677b)},/* Needlesmall_324_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9397,73,(FLASH_DATA_START_ADDR+0x98c7d)},/* Needlesmall_326_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9301,74,(FLASH_DATA_START_ADDR+0x9b133)},/* Needlesmall_328_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9339,75,(FLASH_DATA_START_ADDR+0x9d589)},/* Needlesmall_330_c_g1.bmp */
    {550,300,8,0,0,0,0x89,8833,76,(FLASH_DATA_START_ADDR+0x9fa05)},/* Needlesmall_332_c_g1.bmp */
    {550,300,8,0,0,0,0x89,8897,77,(FLASH_DATA_START_ADDR+0xa1c87)},/* Needlesmall_334_c_g1.bmp */
    {550,300,8,0,0,0,0x89,8800,78,(FLASH_DATA_START_ADDR+0xa3f49)},/* Needlesmall_336_c_g1.bmp */
    {550,300,8,0,0,0,0x89,9003,79,(FLASH_DATA_START_ADDR+0xa61a9)},/* Needlesmall_338_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,8585,80,(FLASH_DATA_START_ADDR+0xa84d5)},/* Needlesmall_340_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,8413,81,(FLASH_DATA_START_ADDR+0xaa65f)},/* Needlesmall_342_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,8217,82,(FLASH_DATA_START_ADDR+0xac73d)},/* Needlesmall_344_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,7922,83,(FLASH_DATA_START_ADDR+0xae757)},/* Needlesmall_346_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,7527,84,(FLASH_DATA_START_ADDR+0xb0649)},/* Needlesmall_348_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,7597,85,(FLASH_DATA_START_ADDR+0xb23b1)},/* Needlesmall_350_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,7073,86,(FLASH_DATA_START_ADDR+0xb415f)},/* Needlesmall_352_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,6870,87,(FLASH_DATA_START_ADDR+0xb5d01)},/* Needlesmall_354_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,6549,88,(FLASH_DATA_START_ADDR+0xb77d7)},/* Needlesmall_356_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,5386,89,(FLASH_DATA_START_ADDR+0xb916d)},/* Needlesmall_358_c_g1.bmp */
    {550,300,8,0,0,0,0x8a,4869,90,(FLASH_DATA_START_ADDR+0xba677)},/* Needlesmall_360_c_g1.bmp */
    {639,440,16,65535,0,0,0x7,72912,91,(FLASH_DATA_START_ADDR+0xbb97d)},/* New3_16bits.bmp */
};

#endif
#define spi_needle_addr  0x600000

//#define FLASH_DATA_START_ADDR 0x100000
CONST BITMAP SystemIcon3[]=
{
	{639,440,16,65535,0,0,0xe,78884,0,(spi_needle_addr+0x07D8DB)},/* New3_16bits.bmp */
};


//---------- Speedo Meter Scale Display using 16bit OSD -------------------

static WORD	 prev0x, prev0y, prev1x, prev1y;
static WORD	 prev0w, prev0h, prev1w, prev1h;
static BYTE	windowNo;

#define	OFFSET_X	80
#define OFFSET_Y	40

//=============================================================================
#define OSD_LUT_WINNO		0x7a
#define OSD_LUT_INDEX		0x7b
#define OSD_LUT_ATTR		0x7c		
#define OSD_LUT_R			0x7d
#define OSD_LUT_G			0x7e
#define OSD_LUT_B			0x7f



//=============================================================================
//		Load 8bit transparent LUT for Speedometer and Clock
//=============================================================================
static void OsdLoadTranparentLUT2(BYTE winno, BYTE red, BYTE green, BYTE blue, BYTE cred, BYTE cgreen, BYTE cblue)
{
	WORD 	i;
	BYTE	r, g, b;

//	dPrintf("\r---> LUT Write with: R:%bd, G:%bd, B:%bd, cR:%bd, cG:%bd, cB:%bd", red, green, blue, cred, cgreen, cblue );

	WriteTW88( 0xff, 0x07 );
	WriteTW88( OSD_LUT_WINNO, winno<<6 );

	for(i=0; i<128; i++) {
		WriteTW88( OSD_LUT_INDEX, i );
		WriteTW88( OSD_LUT_R, cred );
		WriteTW88( OSD_LUT_G, cgreen );
		WriteTW88( OSD_LUT_B, cblue );
		WriteTW88( OSD_LUT_ATTR, 127-i);
	}
	r = g = b = 0;
	for(i=0; i<128; i++) {
		if ( cred ) cred--;			if ( cred ) cred--;
		if ( cgreen ) cgreen--;		if ( cgreen ) cgreen--;
		if ( cblue ) cblue--;		if ( cblue ) cblue--;
		if ( red > r ) r++;			if ( red > r ) r++;
		if ( green > g ) g++;		if ( green > g ) g++;
		if ( blue > b ) b++;			if ( blue > b ) b++;
//		dPrintf("\n\r cred+r=%bx   %bx   %bx\n",cred+r,cgreen+g,cblue+b );
		//Printf("\n\r cgreen+g=%x\n",cgreen+g);
		//Printf("\n\r cblue+b=%x\n",cblue+b);
		WriteTW88( OSD_LUT_INDEX, i+128 );
		WriteTW88( OSD_LUT_R, cred+r );
		WriteTW88( OSD_LUT_G, cgreen+g );
		WriteTW88( OSD_LUT_B, cblue+b );
		WriteTW88( OSD_LUT_ATTR, 0);
	}
	

}




void InitNeedle( void )
{
//WORD	x;

	//OsdLoadTranparentLUT2( 0, 255, 0, 0, 0, 0, 0 );
	//OsdLoadTranparentLUT2( 1, 255, 0, 0, 0, 0, 0 );

	//------------ init Window character
	
	//TWLL_OSDLayer_Init();	
	//#if 0
	//OSD_LoadLUT( 0,8, palette_Speed );
	OsdLoadTranparentLUT2( 0, 255, 0, 0, 0, 0, 0 );
	TWLL_Canvas_Init(&User_Canvasspeed[0]);
	OSD_BlockFill(0, 0, 800, 480, 0, 8);			// color 0 is transparent
	prev0x = prev0y = prev0w = prev0h = 0;
	//WriteTW88( 0xff, 0x07 );
	//WriteTW88( 0x80, 0x30 );			// enable transparent

	//WriteTW88( WIN1_ST, 0x30 );			// enable transparent
	OsdLoadTranparentLUT2( 1, 255, 0, 0, 0, 0, 0 );
	//OSD_LoadLUT( 1,8, palette_Speed );
	TWLL_Canvas_Init(&User_Canvasspeed[1]);
	
	OSD_BlockFill(800, 0, 800, 480, 0, 8);			// color 0 is transparent
	prev1x = prev1y = prev1w = prev1h = 0;
	//WriteTW88( 0xff, 0x07 );
	//WriteTW88( 0xa0, 0x30 );			// enable transparent

	OSD_ShowWindowBmp(0, 0);
	OSD_ShowWindowBmp(1, 0);
	windowNo = 1;
  // #endif
}

void InitScale( void )
{
//	dPrintf("\nMonOSD SpeedoMeter Scale display");
	//Prepare 16bit window with scale
	TWLL_OSDLayer_Init();	
	TWLL_Canvas_Init(&User_Canvasspeed[2]);
	
	OSD_BlockFill(0, 480, 800, 480, 0, 16);			// color 0 is transparent
	
	OSD_LoadBmp((const U8 *)&SystemIcon3[0],80, 520, 16);

	OSD_ShowWindowBmp(0, 0);
	OSD_ShowWindowBmp(1, 0);
	OSD_ShowWindowBmp(2, 1);
	
	

	//WriteTW88( 0xff, OSD_PAGE );
	//WriteTW88( 0xc0, 0x03 );

}


void DrawNeedle( WORD x )
{
//DWORD   spiN;
//BYTE	buffer[8];
BITMAP	pBMP;

#if 0
spiN =  nneedlere[x].start + spi_needle_addr;
pBMP.color_depth = 0x88;
pBMP.compression = 0x88;
pBMP.width=nneedlere[x].right-nneedlere[x].left;
pBMP.height=nneedlere[x].bottom-nneedlere[x].top;
pBMP.bmpdata=nneedlere[x].start+8+spi_needle_addr;
pBMP.data_length=nneedlere[x].length;
Printf("\n\r width=%x, height=%x, length=%lx, bmp=%lx\n",pBMP.width,pBMP.height,pBMP.data_length,pBMP.bmpdata);
OSD_BlockFill(0, 0, 800, 480, 0, 8);
OSD_SetBitmapColorWriteMode(0x34);
OSD_LoadBmp((const U8 *)&pBMP,nneedlere[x].left+80, nneedlere[x].top+40,8 );
OSD_WaitDisplayBlank(1);

#endif    //By Jason

	//Printf("\n\r Winno=%x   x=%x\n", windowNo, x);

	if ( windowNo ) 								// current display is window 1, clear window 1 and display window 0
		{
		//Printf("\n\r Winno=%x   x=%x\n", windowNo, x);
		pBMP.width=nneedlere[x].right-nneedlere[x].left;
		pBMP.height=nneedlere[x].bottom-nneedlere[x].top;
		pBMP.compression=0x88;
		pBMP.color_depth=0x88;
		pBMP.data_length=nneedlere[x].length;
		pBMP.bmpdata=nneedlere[x].start+8+spi_needle_addr;
		OSD_BlockFill(prev0x, prev0y, prev0w, prev0h, 0, 8);			// color 0 is transparent
		//OSD_BlockFill(800, 0, 680, 480, 0, 8);	
		
		//Printf("\n\r width=%x, height=%x, length=%lx, bmp=%lx\n",pBMP.width,pBMP.height,pBMP.data_length,pBMP.bmpdata);
		//Printf("\n\rWindow1  before loading %x\n", windowNo);
		OSD_LoadBmp((const U8 *)&pBMP,nneedlere[x].left+OFFSET_X, nneedlere[x].top+OFFSET_Y,8 );
		
		//Printf("\n\rWindow1  after loading\n");
		prev0x = nneedlere[x].left+OFFSET_X;
		prev0y = nneedlere[x].top+OFFSET_Y;
		prev0w = pBMP.width;
		prev0h = pBMP.height;

		OSD_ShowWindowBmp(0,1);
		//OSD_ShowWindowBmp(1, 1);				// ensable window 0 makes automatically cover window 1
		windowNo = 0;
	}

	else 
		{
		//Printf("\n\r 2 Winno=%x   x=%x\n", windowNo, x);
		// current display is window 0
		//spiN = Needle[x].start + NEEDLE_SPI_START;
		//Printf("\n\r win0 spiN=%lx\n", spiN);
 		//SPI_ReadData2xdata( spiN, &buffer, 8 );
		pBMP.width=nneedlere[x].right-nneedlere[x].left;
		pBMP.height=nneedlere[x].bottom-nneedlere[x].top;
		pBMP.compression=0x88;
		pBMP.color_depth=0x88;
		pBMP.data_length=nneedlere[x].length;
		pBMP.bmpdata=nneedlere[x].start+8+spi_needle_addr;
		//OSD_BlockFill(0, 0, 680, 480, 0, 8);			// color 0 is transparent

		//Printf("\nEnter Here\n");
		
		OSD_BlockFill(800+prev1x, prev1y, prev1w, prev1h, 0, 8);			// color 0 is transparent
		//Printf("\nEnter Here2 x=%x\n",x);
		
		//Printf("\n\r width=%x, height=%x, length=%lx, bmp=%lx\n",pBMP.width,pBMP.height,pBMP.data_length,pBMP.bmpdata);
		OSD_LoadBmp((const U8 *)&pBMP,800+nneedlere[x].left+OFFSET_X, nneedlere[x].top+OFFSET_Y,8 );
		//Printf("\n\rAfter Loding lll\n");
		//if(x>45)
		//	OSD_LoadBmp((const U8 *)&SystemIcon3[x],120, 40, 8);
		//else
		//	OSD_LoadBmp((const U8 *)&SystemIcon3[x],130, 40, 8);
		prev1x = nneedlere[x].left+OFFSET_X;
		prev1y = nneedlere[x].top+OFFSET_Y;
		prev1w = pBMP.width;
		prev1h = pBMP.height;
		OSD_WaitDisplayBlank(1);
		//Printf("\n\rAfter Loding 222\n");
		OSD_ShowWindowBmp(0, 0);
		//Printf("\n\rAfter Loding 333\n");// disable window 0 makes automatically display window 1
		//OSD_ShowWindowBmp(1,0);
		windowNo = 1;

	}

}


void SpeedoMeterDemo( void )
{
	WORD i;
	BYTE mode=0, current=0,direction=1,step=1, next;
	BOOL ret,flag;
	CMDST touchcmd;
	OSD_ShowWindowBmp(0, 0);					// OFF the display
	OSD_ShowWindowBmp(1, 0);
	OSD_ShowWindowBmp(2, 0);
	InitScale();
	InitNeedle();
	DrawNeedle(0);
	OSD_ShowWindowBmp(0, 1);					// OFF the display
	OSD_ShowWindowBmp(1, 1);
	OSD_ShowWindowBmp(2, 1);

//	for(i=0;i<180;i++)
//		DrawNeedle(i);

//	while(1);
	
	
	while (1) {
	 				// auto mode only
			if ( direction ) {			// acceleration
				next = current + step;
				if ( next > 180 ) {
					next = 180;
					direction = 0;		// change to decrease
				}
				DrawNeedle( next );
				current = next;
			}
			else {
				if ( current > step )
					next = current - step;
				else   {
					next = 0;
					direction = 1;		// change to decrease
				}
				DrawNeedle( next );
				current = next;
			}
			
		ret=CheckTSCCMD(&touchcmd);
		if(ret)
			{
				if(touchcmd.Cmdbuf[0]==0)
					flag=TRUE;
				if ( touchcmd.Cmdbuf[0]== 0 ) 
					{
						if (( touchcmd.Cmdbuf[1] > 700 ) && ( (touchcmd.Cmdbuf[2]&0x1fff)  >400 )) 
							{
				//				Printf("\nEnter Break\n");
								goto RET;
							}
					}
				if(flag&&((touchcmd.Cmdbuf[1]-touchcmd.Cmdbuf[3])>50)&&(touchcmd.Cmdbuf[1]>touchcmd.Cmdbuf[3]))     //moveup
				{	

					step++;
					if(step>8)
						step=8;
				//	Printf("\n cmdbuf[1]=%x,   %x  Step0=%bx\n", touchcmd.Cmdbuf[1],touchcmd.Cmdbuf[3],step);
					flag=FALSE;
				}
				else if(flag&&((touchcmd.Cmdbuf[3]-touchcmd.Cmdbuf[1])>50)&&(touchcmd.Cmdbuf[1]<touchcmd.Cmdbuf[3]))  //move down
				{
					step--;
		    		if(step==0)
						step=1;
				//	Printf("\n lll=%x,   %x  Step0=%bx\n", touchcmd.Cmdbuf[1],touchcmd.Cmdbuf[3], step);
					flag=FALSE;
					
				}
			}
		}
		RET:  
			//Printf("\n\r Exit Rose Demo\n");
			OSD_ShowWindowBmp(0, 0);					// OFF the display
			OSD_ShowWindowBmp(1, 0);
			OSD_ShowWindowBmp(2, 0);
	
		//else if ( ts == 	TOUCHDOUBLECLICK ) {
		//	Puts("\nTouch double clicked!!!");
		//	SetTouchStatus( 0 );			// clear status
		//	return( REMO_TWLL_EXIT );
		//	break;
		//}
	

    #if 0
	
	for(i=0;i<91;i++)
		{
			DrawNeedle( i );
			OSD_WaitDisplayBlank(1);
			OSD_WaitDisplayBlank(1);
			OSD_WaitDisplayBlank(1);
			//OSD_WaitDisplayBlank(1);
			//OSD_WaitDisplayBlank(1);
			//OSD_WaitDisplayBlank(1);
			//OSD_WaitDisplayBlank(1);
			//OSD_WaitDisplayBlank(1);
			//OSD_WaitDisplayBlank(1);
			//OSD_WaitDisplayBlank(1);
			
			//OSD_WaitDisplayBlank(1);

		}
	

	//OSD_ShowWindowBmp(0, 1);					// OFF the display
	//OSD_ShowWindowBmp(1, 0);
	OSD_ShowWindowBmp(2, 1);
	#endif
	//OsdWinDisplay( 3 );						// OFF the display
	

}
#endif
//erek 2010-7-19

CONST ATTRIBUTE canvas0s_attr[]={
{0x01, 0x02, 0x00, 0, 0},// color alpha blending
{0x02, 0x00, 0x00, 0, 0},//color blinking
{0xff,0,0,0}
};


CONST ATTRIBUTE canvas1s_attr[]={
{0x01, 0x02, 0x00, 0, 0},// color alpha blending
{0x02, 0x00, 0x00, 0, 0},//color blinking
{0xff,0,0,0}
};

CANVAS User_Canvasspeed[]={
    {0, 0, 0, 0, 0, 8, 800, 480, canvas0s_attr, 0},
    {800, 0, 0, 0, 1, 8, 800, 480, canvas1s_attr, 1},
    //{0, 480, 0, 0, 2, 16, 800, 480, canvas2s_attr, 2},
};

CONST PALETTEENTRY  Speedmeter_0_LUT[] = {    // LUT
    0x00, 0x00, 0x00, 0x7f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 
    0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 
    0xc0, 0xdc, 0xc0, 0x00, 0xa6, 0xca, 0xf0, 0x00, 0x40, 0x20, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 
    0x80, 0x20, 0x00, 0x00, 0xa0, 0x20, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xe0, 0x20, 0x00, 0x00, 
    0x00, 0x40, 0x00, 0x00, 0x20, 0x40, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x60, 0x40, 0x00, 0x00, 
    0x80, 0x40, 0x00, 0x00, 0xa0, 0x40, 0x00, 0x00, 0xc0, 0x40, 0x00, 0x00, 0xe0, 0x40, 0x00, 0x00, 
    0x00, 0x60, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x40, 0x60, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 
    0x80, 0x60, 0x00, 0x00, 0xa0, 0x60, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 
    0x00, 0x80, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 
    0x80, 0x80, 0x00, 0x00, 0xa0, 0x80, 0x00, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xe0, 0x80, 0x00, 0x00, 
    0x00, 0xa0, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x60, 0xa0, 0x00, 0x00, 
    0x80, 0xa0, 0x00, 0x00, 0xa0, 0xa0, 0x00, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xe0, 0xa0, 0x00, 0x00, 
    0x00, 0xc0, 0x00, 0x00, 0x20, 0xc0, 0x00, 0x00, 0x40, 0xc0, 0x00, 0x00, 0x60, 0xc0, 0x00, 0x00, 
    0x80, 0xc0, 0x00, 0x00, 0xa0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xe0, 0xc0, 0x00, 0x00, 
    0x00, 0xe0, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 
    0x80, 0xe0, 0x00, 0x00, 0xa0, 0xe0, 0x00, 0x00, 0xc0, 0xe0, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x00, 
    0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x60, 0x00, 0x40, 0x00, 
    0x80, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x40, 0x00, 0xc0, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x40, 0x00, 
    0x00, 0x20, 0x40, 0x00, 0x20, 0x20, 0x40, 0x00, 0x40, 0x20, 0x40, 0x00, 0x60, 0x20, 0x40, 0x00, 
    0x80, 0x20, 0x40, 0x00, 0xa0, 0x20, 0x40, 0x00, 0xc0, 0x20, 0x40, 0x00, 0xe0, 0x20, 0x40, 0x00, 
    0x00, 0x40, 0x40, 0x00, 0x20, 0x40, 0x40, 0x00, 0x40, 0x40, 0x40, 0x00, 0x60, 0x40, 0x40, 0x00, 
    0x80, 0x40, 0x40, 0x00, 0xa0, 0x40, 0x40, 0x00, 0xc0, 0x40, 0x40, 0x00, 0xe0, 0x40, 0x40, 0x00, 
    0x00, 0x60, 0x40, 0x00, 0x20, 0x60, 0x40, 0x00, 0x40, 0x60, 0x40, 0x00, 0x60, 0x60, 0x40, 0x00, 
    0x80, 0x60, 0x40, 0x00, 0xa0, 0x60, 0x40, 0x00, 0xc0, 0x60, 0x40, 0x00, 0xe0, 0x60, 0x40, 0x00, 
    0x00, 0x80, 0x40, 0x00, 0x20, 0x80, 0x40, 0x00, 0x40, 0x80, 0x40, 0x00, 0x60, 0x80, 0x40, 0x00, 
    0x80, 0x80, 0x40, 0x00, 0xa0, 0x80, 0x40, 0x00, 0xc0, 0x80, 0x40, 0x00, 0xe0, 0x80, 0x40, 0x00, 
    0x00, 0xa0, 0x40, 0x00, 0x20, 0xa0, 0x40, 0x00, 0x40, 0xa0, 0x40, 0x00, 0x60, 0xa0, 0x40, 0x00, 
    0x80, 0xa0, 0x40, 0x00, 0xa0, 0xa0, 0x40, 0x00, 0xc0, 0xa0, 0x40, 0x00, 0xe0, 0xa0, 0x40, 0x00, 
    0x00, 0xc0, 0x40, 0x00, 0x20, 0xc0, 0x40, 0x00, 0x40, 0xc0, 0x40, 0x00, 0x60, 0xc0, 0x40, 0x00, 
    0x80, 0xc0, 0x40, 0x00, 0xa0, 0xc0, 0x40, 0x00, 0xc0, 0xc0, 0x40, 0x00, 0xe0, 0xc0, 0x40, 0x00, 
    0x00, 0xe0, 0x40, 0x00, 0x20, 0xe0, 0x40, 0x00, 0x40, 0xe0, 0x40, 0x00, 0x60, 0xe0, 0x40, 0x00, 
    0x80, 0xe0, 0x40, 0x00, 0xa0, 0xe0, 0x40, 0x00, 0xc0, 0xe0, 0x40, 0x00, 0xe0, 0xe0, 0x40, 0x00, 
    0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, 0x40, 0x00, 0x80, 0x00, 0x60, 0x00, 0x80, 0x00, 
    0x80, 0x00, 0x80, 0x00, 0xa0, 0x00, 0x80, 0x00, 0xc0, 0x00, 0x80, 0x00, 0xe0, 0x00, 0x80, 0x00, 
    0x00, 0x20, 0x80, 0x00, 0x20, 0x20, 0x80, 0x00, 0x40, 0x20, 0x80, 0x00, 0x60, 0x20, 0x80, 0x00, 
    0x80, 0x20, 0x80, 0x00, 0xa0, 0x20, 0x80, 0x00, 0xc0, 0x20, 0x80, 0x00, 0xe0, 0x20, 0x80, 0x00, 
    0x00, 0x40, 0x80, 0x00, 0x20, 0x40, 0x80, 0x00, 0x40, 0x40, 0x80, 0x00, 0x60, 0x40, 0x80, 0x00, 
    0x80, 0x40, 0x80, 0x00, 0xa0, 0x40, 0x80, 0x00, 0xc0, 0x40, 0x80, 0x00, 0xe0, 0x40, 0x80, 0x00, 
    0x00, 0x60, 0x80, 0x00, 0x20, 0x60, 0x80, 0x00, 0x40, 0x60, 0x80, 0x00, 0x60, 0x60, 0x80, 0x00, 
    0x80, 0x60, 0x80, 0x00, 0xa0, 0x60, 0x80, 0x00, 0xc0, 0x60, 0x80, 0x00, 0xe0, 0x60, 0x80, 0x00, 
    0x00, 0x80, 0x80, 0x00, 0x20, 0x80, 0x80, 0x00, 0x40, 0x80, 0x80, 0x00, 0x60, 0x80, 0x80, 0x00, 
    0x80, 0x80, 0x80, 0x00, 0xa0, 0x80, 0x80, 0x00, 0xc0, 0x80, 0x80, 0x00, 0xe0, 0x80, 0x80, 0x00, 
    0x00, 0xa0, 0x80, 0x00, 0x20, 0xa0, 0x80, 0x00, 0x40, 0xa0, 0x80, 0x00, 0x60, 0xa0, 0x80, 0x00, 
    0x80, 0xa0, 0x80, 0x00, 0xa0, 0xa0, 0x80, 0x00, 0xc0, 0xa0, 0x80, 0x00, 0xe0, 0xa0, 0x80, 0x00, 
    0x00, 0xc0, 0x80, 0x00, 0x20, 0xc0, 0x80, 0x00, 0x40, 0xc0, 0x80, 0x00, 0x60, 0xc0, 0x80, 0x00, 
    0x80, 0xc0, 0x80, 0x00, 0xa0, 0xc0, 0x80, 0x00, 0xc0, 0xc0, 0x80, 0x00, 0xe0, 0xc0, 0x80, 0x00, 
    0x00, 0xe0, 0x80, 0x00, 0x20, 0xe0, 0x80, 0x00, 0x40, 0xe0, 0x80, 0x00, 0x60, 0xe0, 0x80, 0x00, 
    0x80, 0xe0, 0x80, 0x00, 0xa0, 0xe0, 0x80, 0x00, 0xc0, 0xe0, 0x80, 0x00, 0xe0, 0xe0, 0x80, 0x00, 
    0x00, 0x00, 0xc0, 0x00, 0x20, 0x00, 0xc0, 0x00, 0x40, 0x00, 0xc0, 0x00, 0x60, 0x00, 0xc0, 0x00, 
    0x80, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xc0, 0x00, 
    0x00, 0x20, 0xc0, 0x00, 0x20, 0x20, 0xc0, 0x00, 0x40, 0x20, 0xc0, 0x00, 0x60, 0x20, 0xc0, 0x00, 
    0x80, 0x20, 0xc0, 0x00, 0xa0, 0x20, 0xc0, 0x00, 0xc0, 0x20, 0xc0, 0x00, 0xe0, 0x20, 0xc0, 0x00, 
    0x00, 0x40, 0xc0, 0x00, 0x20, 0x40, 0xc0, 0x00, 0x40, 0x40, 0xc0, 0x00, 0x60, 0x40, 0xc0, 0x00, 
    0x80, 0x40, 0xc0, 0x00, 0xa0, 0x40, 0xc0, 0x00, 0xc0, 0x40, 0xc0, 0x00, 0xe0, 0x40, 0xc0, 0x00, 
    0x00, 0x60, 0xc0, 0x00, 0x20, 0x60, 0xc0, 0x00, 0x40, 0x60, 0xc0, 0x00, 0x60, 0x60, 0xc0, 0x00, 
    0x80, 0x60, 0xc0, 0x00, 0xa0, 0x60, 0xc0, 0x00, 0xc0, 0x60, 0xc0, 0x00, 0xe0, 0x60, 0xc0, 0x00, 
    0x00, 0x80, 0xc0, 0x00, 0x20, 0x80, 0xc0, 0x00, 0x40, 0x80, 0xc0, 0x00, 0x60, 0x80, 0xc0, 0x00, 
    0x80, 0x80, 0xc0, 0x00, 0xa0, 0x80, 0xc0, 0x00, 0xc0, 0x80, 0xc0, 0x00, 0xe0, 0x80, 0xc0, 0x00, 
    0x00, 0xa0, 0xc0, 0x00, 0x20, 0xa0, 0xc0, 0x00, 0x40, 0xa0, 0xc0, 0x00, 0x60, 0xa0, 0xc0, 0x00, 
    0x80, 0xa0, 0xc0, 0x00, 0xa0, 0xa0, 0xc0, 0x00, 0xc0, 0xa0, 0xc0, 0x00, 0xe0, 0xa0, 0xc0, 0x00, 
    0x00, 0xc0, 0xc0, 0x00, 0x20, 0xc0, 0xc0, 0x00, 0x40, 0xc0, 0xc0, 0x00, 0x60, 0xc0, 0xc0, 0x00, 
    0x80, 0xc0, 0xc0, 0x00, 0xa0, 0xc0, 0xc0, 0x00, 0xff, 0xfb, 0xf0, 0x00, 0xa0, 0xa0, 0xa4, 0x00, 
    0x80, 0x80, 0x80, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 
    0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 
};

#define spi_speedneedle_addr  0x93e36c
#define spi_oilneedle_addr  0x960234

#define	Speed_OFFSET_X	259
#define Speed_OFFSET_Y	118
#define	Oil_OFFSET_X	49
#define Oil_OFFSET_Y	140

typedef struct { 
    DWORD start;
    DWORD length;
    WORD left;
    WORD top;
    WORD right;
    WORD bottom;
    unsigned char rle_bits;
} SPIIMAGE;

FAR CONST SPIIMAGE Speedneedlere[] = {
{0x000000, 0x000042, 0,128,151,152,0x89 },  // r0
{0x000042, 0x000099, 0,126,151,152,0x88 },  // r1
{0x0000db, 0x0000e7, 0,123,151,152,0x88 },  // r2
{0x0001c2, 0x00012f, 0,121,152,153,0x87 },  // r3
{0x0002f1, 0x000164, 0,118,152,153,0x87 },  // r4
{0x000455, 0x00018f, 0,116,152,153,0x87 },  // r5
{0x0005e4, 0x0001ad, 0,114,152,153,0x87 },  // r6
{0x000791, 0x0001dc, 0,111,152,153,0x87 },  // r7
{0x00096d, 0x0001f7, 0,109,152,154,0x87 },  // r8
{0x000b64, 0x00020c, 0,106,153,154,0x87 },  // r9
{0x000d70, 0x00021a, 0,104,153,154,0x87 },  // r10
{0x000f8a, 0x000220, 0,102,153,154,0x88 },  // r11
{0x0011aa, 0x000233, 0,99,153,154,0x88 },  // r12
{0x0013dd, 0x00023a, 1,97,153,154,0x88 },  // r13
{0x001617, 0x00025d, 1,95,153,155,0x88 },  // r14
{0x001874, 0x000254, 1,92,153,155,0x88 },  // r15
{0x001ac8, 0x00025f, 2,90,154,155,0x88 },  // r16
{0x001d27, 0x000268, 2,88,154,155,0x88 },  // r17
{0x001f8f, 0x000273, 3,86,154,155,0x88 },  // r18
{0x002202, 0x00027c, 3,83,154,155,0x88 },  // r19
{0x00247e, 0x000285, 4,81,154,155,0x88 },  // r20
{0x002703, 0x00028c, 5,79,154,155,0x88 },  // r21
{0x00298f, 0x000295, 5,77,154,156,0x88 },  // r22
{0x002c24, 0x00029c, 6,75,154,156,0x88 },  // r23
{0x002ec0, 0x0002a7, 7,72,154,156,0x88 },  // r24
{0x003167, 0x0002b2, 8,70,155,156,0x88 },  // r25
{0x003419, 0x0002be, 8,68,155,156,0x88 },  // r26
{0x0036d7, 0x0002c3, 9,66,155,156,0x88 },  // r27
{0x00399a, 0x0002ce, 10,64,155,156,0x88 },  // r28
{0x003c68, 0x0002d7, 11,62,155,156,0x88 },  // r29
{0x003f3f, 0x0002df, 12,60,155,156,0x87 },  // r30
{0x00421e, 0x0002e3, 13,58,155,156,0x87 },  // r31
{0x004501, 0x0002dd, 14,56,155,156,0x87 },  // r32
{0x0047de, 0x0002f5, 15,54,155,156,0x87 },  // r33
{0x004ad3, 0x0002fd, 16,52,155,156,0x87 },  // r34
{0x004dd0, 0x000308, 18,50,155,157,0x87 },  // r35
{0x0050d8, 0x00030d, 19,48,155,157,0x87 },  // r36
{0x0053e5, 0x00030e, 20,47,155,157,0x87 },  // r37
{0x0056f3, 0x000317, 21,45,155,157,0x87 },  // r38
{0x005a0a, 0x00031d, 23,43,155,157,0x87 },  // r39
{0x005d27, 0x000326, 24,41,155,157,0x87 },  // r40
{0x00604d, 0x000329, 26,40,155,157,0x87 },  // r41
{0x006376, 0x000334, 27,38,155,157,0x87 },  // r42
{0x0066aa, 0x00033b, 28,36,155,157,0x87 },  // r43
{0x0069e5, 0x000341, 30,35,155,157,0x87 },  // r44
{0x006d26, 0x00038f, 32,33,155,157,0x87 },  // r45
{0x0070b5, 0x00034b, 33,31,155,157,0x87 },  // r46
{0x007400, 0x000352, 35,30,155,157,0x87 },  // r47
{0x007752, 0x00035b, 36,28,155,157,0x87 },  // r48
{0x007aad, 0x00035e, 38,27,155,157,0x87 },  // r49
{0x007e0b, 0x000365, 40,25,155,157,0x87 },  // r50
{0x008170, 0x00036b, 41,24,155,157,0x87 },  // r51
{0x0084db, 0x00036e, 43,23,155,156,0x87 },  // r52
{0x008849, 0x00037b, 45,21,155,156,0x87 },  // r53
{0x008bc4, 0x00037d, 47,20,155,156,0x87 },  // r54
{0x008f41, 0x000384, 49,19,155,156,0x87 },  // r55
{0x0092c5, 0x000388, 50,18,155,156,0x87 },  // r56
{0x00964d, 0x00038a, 52,16,155,156,0x87 },  // r57
{0x0099d7, 0x000388, 54,15,155,156,0x87 },  // r58
{0x009d5f, 0x000398, 56,14,155,156,0x87 },  // r59
{0x00a0f7, 0x000398, 58,13,155,156,0x87 },  // r60
{0x00a48f, 0x00039b, 60,12,154,156,0x87 },  // r61
{0x00a82a, 0x00039f, 62,11,154,156,0x87 },  // r62
{0x00abc9, 0x00039f, 64,10,154,156,0x87 },  // r63
{0x00af68, 0x0003ac, 66,9,154,155,0x87 },  // r64
{0x00b314, 0x0003a9, 68,8,154,155,0x87 },  // r65
{0x00b6bd, 0x0003ac, 71,8,154,155,0x87 },  // r66
{0x00ba69, 0x0003b0, 73,7,154,155,0x87 },  // r67
{0x00be19, 0x0003b5, 75,6,154,155,0x87 },  // r68
{0x00c1ce, 0x0003bb, 77,5,154,155,0x87 },  // r69
{0x00c589, 0x0003a7, 79,5,153,155,0x86 },  // r70
{0x00c930, 0x0003a9, 81,4,153,155,0x86 },  // r71
{0x00ccd9, 0x0003aa, 84,3,153,154,0x86 },  // r72
{0x00d083, 0x0003a7, 86,3,153,154,0x86 },  // r73
{0x00d42a, 0x0003a9, 88,2,153,154,0x86 },  // r74
{0x00d7d3, 0x0003ad, 90,2,153,154,0x86 },  // r75
{0x00db80, 0x000393, 93,1,153,154,0x86 },  // r76
{0x00df13, 0x0003ac, 95,1,152,154,0x86 },  // r77
{0x00e2bf, 0x0003ad, 97,1,152,153,0x86 },  // r78
{0x00e66c, 0x0003ad, 100,1,152,153,0x86 },  // r79
{0x00ea19, 0x0003ad, 102,1,152,153,0x86 },  // r80
{0x00edc6, 0x0003b0, 104,1,152,153,0x86 },  // r81
{0x00f176, 0x0003b3, 107,1,152,153,0x86 },  // r82
{0x00f529, 0x000398, 109,1,151,152,0x85 },  // r83
{0x00f8c1, 0x000392, 112,1,151,152,0x85 },  // r84
{0x00fc53, 0x000393, 114,1,151,152,0x85 },  // r85
{0x00ffe6, 0x00038d, 116,1,151,152,0x85 },  // r86
{0x010373, 0x000388, 119,1,151,152,0x85 },  // r87
{0x0106fb, 0x000385, 121,1,150,151,0x85 },  // r88
{0x010a80, 0x00035c, 124,1,150,151,0x84 },  // r89
{0x010ddc, 0x000292, 126,1,150,151,0x84 },  // r90
{0x01106e, 0x000359, 126,1,152,151,0x84 },  // r91
{0x0113c7, 0x000389, 126,1,155,151,0x85 },  // r92
{0x011750, 0x000389, 125,1,157,152,0x85 },  // r93
{0x011ad9, 0x000389, 125,1,160,152,0x85 },  // r94
{0x011e62, 0x000390, 125,1,162,152,0x85 },  // r95
{0x0121f2, 0x00038c, 125,1,164,152,0x85 },  // r96
{0x01257e, 0x000394, 125,1,167,152,0x85 },  // r97
{0x012912, 0x0003b4, 124,1,169,152,0x86 },  // r98
{0x012cc6, 0x0003b3, 124,1,172,153,0x86 },  // r99
{0x013079, 0x0003ad, 124,1,174,153,0x86 },  // r100
{0x013426, 0x0003ab, 124,1,176,153,0x86 },  // r101
{0x0137d1, 0x0003af, 124,1,179,153,0x86 },  // r102
{0x013b80, 0x0003ae, 124,1,181,153,0x86 },  // r103
{0x013f2e, 0x0003c2, 123,1,183,153,0x86 },  // r104
{0x0142f0, 0x0003ae, 123,1,186,153,0x86 },  // r105
{0x01469e, 0x0003ad, 123,2,188,154,0x86 },  // r106
{0x014a4b, 0x0003ae, 123,2,190,154,0x86 },  // r107
{0x014df9, 0x0003ae, 123,3,192,154,0x86 },  // r108
{0x0151a7, 0x0003ab, 123,3,195,154,0x86 },  // r109
{0x015552, 0x0003ae, 123,4,197,154,0x86 },  // r110
{0x015900, 0x0003bb, 123,5,199,154,0x87 },  // r111
{0x015cbb, 0x0003b7, 122,5,201,154,0x87 },  // r112
{0x016072, 0x0003b0, 122,6,203,154,0x87 },  // r113
{0x016422, 0x0003af, 122,7,206,154,0x87 },  // r114
{0x0167d1, 0x0003ad, 122,8,208,155,0x87 },  // r115
{0x016b7e, 0x0003ae, 122,8,210,155,0x87 },  // r116
{0x016f2c, 0x0003a4, 122,9,212,155,0x87 },  // r117
{0x0172d0, 0x0003a1, 122,10,214,155,0x87 },  // r118
{0x017671, 0x00039e, 122,11,216,155,0x87 },  // r119
{0x017a0f, 0x000397, 122,12,218,155,0x87 },  // r120
{0x017da6, 0x000391, 122,13,220,155,0x87 },  // r121
{0x018137, 0x00037f, 122,14,222,155,0x87 },  // r122
{0x0184b6, 0x00038d, 122,15,224,155,0x87 },  // r123
{0x018843, 0x000388, 122,16,226,155,0x87 },  // r124
{0x018bcb, 0x000387, 121,18,228,155,0x87 },  // r125
{0x018f52, 0x000381, 121,19,230,155,0x87 },  // r126
{0x0192d3, 0x000377, 121,20,231,155,0x87 },  // r127
{0x01964a, 0x000373, 121,21,233,155,0x87 },  // r128
{0x0199bd, 0x00036e, 121,23,235,155,0x87 },  // r129
{0x019d2b, 0x000368, 121,24,237,155,0x87 },  // r130
{0x01a093, 0x00035e, 121,26,238,155,0x87 },  // r131
{0x01a3f1, 0x00035c, 121,27,240,155,0x87 },  // r132
{0x01a74d, 0x000355, 121,28,242,155,0x87 },  // r133
{0x01aaa2, 0x000350, 121,30,243,155,0x87 },  // r134
{0x01adf2, 0x000390, 121,32,245,155,0x87 },  // r135
{0x01b182, 0x00033e, 121,33,247,155,0x87 },  // r136
{0x01b4c0, 0x000339, 121,35,248,155,0x87 },  // r137
{0x01b7f9, 0x000332, 121,36,250,155,0x87 },  // r138
{0x01bb2b, 0x00032e, 121,38,251,155,0x87 },  // r139
{0x01be59, 0x000327, 121,40,253,155,0x87 },  // r140
{0x01c180, 0x000320, 121,41,254,155,0x87 },  // r141
{0x01c4a0, 0x000317, 122,43,255,155,0x87 },  // r142
{0x01c7b7, 0x000317, 122,45,257,155,0x87 },  // r143
{0x01cace, 0x00030d, 122,47,258,155,0x87 },  // r144
{0x01cddb, 0x000308, 122,49,259,155,0x87 },  // r145
{0x01d0e3, 0x000301, 122,50,260,155,0x87 },  // r146
{0x01d3e4, 0x0002f7, 122,52,262,155,0x87 },  // r147
{0x01d6db, 0x0002ea, 122,54,263,155,0x87 },  // r148
{0x01d9c5, 0x0002ee, 122,56,264,155,0x87 },  // r149
{0x01dcb3, 0x0002e2, 122,58,265,155,0x88 },  // r150
{0x01df95, 0x0002d8, 122,60,266,154,0x88 },  // r151
{0x01e26d, 0x0002cf, 122,62,267,154,0x88 },  // r152
{0x01e53c, 0x0002c1, 122,64,268,154,0x88 },  // r153
{0x01e7fd, 0x0002c1, 123,66,269,154,0x88 },  // r154
{0x01eabe, 0x0002b1, 123,68,270,154,0x88 },  // r155
{0x01ed6f, 0x0002a7, 123,71,270,154,0x88 },  // r156
{0x01f016, 0x0002a0, 123,73,271,154,0x88 },  // r157
{0x01f2b6, 0x000297, 123,75,272,154,0x88 },  // r158
{0x01f54d, 0x000290, 123,77,273,154,0x88 },  // r159
{0x01f7dd, 0x000285, 123,79,273,153,0x88 },  // r160
{0x01fa62, 0x00027e, 123,81,274,153,0x88 },  // r161
{0x01fce0, 0x000276, 124,84,275,153,0x88 },  // r162
{0x01ff56, 0x000266, 124,86,275,153,0x88 },  // r163
{0x0201bc, 0x00025b, 124,88,276,153,0x88 },  // r164
{0x020417, 0x000255, 124,90,276,153,0x88 },  // r165
{0x02066c, 0x000231, 124,93,277,153,0x88 },  // r166
{0x02089d, 0x00023a, 124,95,277,152,0x88 },  // r167
{0x020ad7, 0x000233, 125,97,277,152,0x88 },  // r168
{0x020d0a, 0x000224, 125,100,277,152,0x87 },  // r169
{0x020f2e, 0x00021a, 125,102,277,152,0x87 },  // r170
{0x021148, 0x00020a, 125,104,277,152,0x87 },  // r171
{0x021352, 0x0001f8, 125,107,277,152,0x87 },  // r172
{0x02154a, 0x0001e3, 126,109,277,151,0x87 },  // r173
{0x02172d, 0x0001bb, 126,112,277,151,0x87 },  // r174
{0x0218e8, 0x000194, 126,114,277,151,0x87 },  // r175
{0x021a7c, 0x000168, 126,116,277,151,0x87 },  // r176
{0x021be4, 0x000127, 126,119,277,151,0x87 },  // r177
{0x021d0b, 0x0000e6, 127,121,277,150,0x88 },  // r178
{0x021df1, 0x000095, 127,124,277,150,0x88 },  // r179
{0x021e86, 0x000042, 127,126,277,150,0x89 },  // r180
};

FAR CONST SPIIMAGE Oilneedlere[] = {
{0x000000, 0x000036, 0,108,130,132,0x89 },  // r0
{0x000036, 0x00007d, 0,106,130,132,0x88 },  // r1
{0x0000b3, 0x0000c2, 0,104,130,132,0x87 },  // r2
{0x000175, 0x0000fe, 0,102,131,133,0x87 },  // r3
{0x000273, 0x00012c, 0,100,131,133,0x87 },  // r4
{0x00039f, 0x00014e, 0,98,131,133,0x87 },  // r5
{0x0004ed, 0x00016e, 0,96,131,133,0x87 },  // r6
{0x00065b, 0x00018e, 0,94,131,133,0x87 },  // r7
{0x0007e9, 0x0001a6, 0,92,131,133,0x87 },  // r8
{0x00098f, 0x0001b7, 0,90,132,134,0x87 },  // r9
{0x000b46, 0x0001c0, 0,88,132,134,0x87 },  // r10
{0x000d06, 0x0001d4, 0,85,132,134,0x87 },  // r11
{0x000eda, 0x0001d9, 0,83,132,134,0x87 },  // r12
{0x0010b3, 0x0001ec, 0,82,132,134,0x87 },  // r13
{0x00129f, 0x000204, 0,80,132,134,0x87 },  // r14
{0x0014a3, 0x0001f6, 1,78,132,134,0x87 },  // r15
{0x001699, 0x0001fc, 1,76,133,135,0x87 },  // r16
{0x001895, 0x000208, 1,74,133,135,0x87 },  // r17
{0x001a9d, 0x00020d, 2,72,133,135,0x87 },  // r18
{0x001caa, 0x000218, 2,70,133,135,0x87 },  // r19
{0x001ec2, 0x00021e, 3,68,133,135,0x87 },  // r20
{0x0020e0, 0x000227, 3,66,133,135,0x87 },  // r21
{0x002307, 0x00022e, 4,64,133,135,0x87 },  // r22
{0x002535, 0x000235, 4,62,133,135,0x87 },  // r23
{0x00276a, 0x00023b, 5,61,134,135,0x87 },  // r24
{0x0029a5, 0x000240, 6,59,134,135,0x87 },  // r25
{0x002be5, 0x00024e, 6,57,134,136,0x87 },  // r26
{0x002e33, 0x000253, 7,55,134,136,0x87 },  // r27
{0x003086, 0x00025a, 8,53,134,136,0x87 },  // r28
{0x0032e0, 0x000261, 9,52,134,136,0x87 },  // r29
{0x003541, 0x00026a, 9,50,134,136,0x87 },  // r30
{0x0037ab, 0x000278, 10,48,134,136,0x87 },  // r31
{0x003a23, 0x00027b, 11,47,134,136,0x87 },  // r32
{0x003c9e, 0x00027d, 12,45,134,136,0x87 },  // r33
{0x003f1b, 0x00028a, 13,43,134,136,0x87 },  // r34
{0x0041a5, 0x000283, 14,42,134,136,0x87 },  // r35
{0x004428, 0x000291, 15,40,134,136,0x87 },  // r36
{0x0046b9, 0x000295, 16,39,134,136,0x87 },  // r37
{0x00494e, 0x00029f, 17,37,134,136,0x87 },  // r38
{0x004bed, 0x0002a2, 18,36,134,136,0x87 },  // r39
{0x004e8f, 0x0002ab, 19,34,134,136,0x87 },  // r40
{0x00513a, 0x0002b0, 21,33,135,136,0x87 },  // r41
{0x0053ea, 0x0002b5, 22,31,135,136,0x87 },  // r42
{0x00569f, 0x0002bb, 23,30,135,136,0x87 },  // r43
{0x00595a, 0x0002c3, 24,28,135,136,0x87 },  // r44
{0x005c1d, 0x0002aa, 26,27,135,136,0x87 },  // r45
{0x005ec7, 0x0002ce, 27,26,135,136,0x87 },  // r46
{0x006195, 0x0002d4, 28,24,135,136,0x87 },  // r47
{0x006469, 0x0002d6, 30,23,135,136,0x87 },  // r48
{0x00673f, 0x0002da, 31,22,135,136,0x87 },  // r49
{0x006a19, 0x0002e2, 33,21,134,136,0x87 },  // r50
{0x006cfb, 0x0002e8, 34,20,134,136,0x87 },  // r51
{0x006fe3, 0x0002eb, 35,18,134,136,0x87 },  // r52
{0x0072ce, 0x0002f2, 37,17,134,136,0x87 },  // r53
{0x0075c0, 0x0002f1, 39,16,134,136,0x87 },  // r54
{0x0078b1, 0x0002f6, 40,15,134,135,0x87 },  // r55
{0x007ba7, 0x0002f9, 42,14,134,135,0x87 },  // r56
{0x007ea0, 0x0002ff, 43,13,134,135,0x87 },  // r57
{0x00819f, 0x000313, 45,12,134,135,0x87 },  // r58
{0x0084b2, 0x000305, 47,11,134,135,0x87 },  // r59
{0x0087b7, 0x000310, 48,10,134,135,0x87 },  // r60
{0x008ac7, 0x000312, 50,10,134,135,0x87 },  // r61
{0x008dd9, 0x000315, 52,9,134,135,0x87 },  // r62
{0x0090ee, 0x00031a, 53,8,134,135,0x87 },  // r63
{0x009408, 0x00031a, 55,7,134,135,0x87 },  // r64
{0x009722, 0x00031f, 57,7,134,134,0x87 },  // r65
{0x009a41, 0x000326, 59,6,134,134,0x87 },  // r66
{0x009d67, 0x000315, 61,5,133,134,0x86 },  // r67
{0x00a07c, 0x000315, 62,5,133,134,0x86 },  // r68
{0x00a391, 0x000318, 64,4,133,134,0x86 },  // r69
{0x00a6a9, 0x00031a, 66,3,133,134,0x86 },  // r70
{0x00a9c3, 0x000319, 68,3,133,134,0x86 },  // r71
{0x00acdc, 0x000319, 70,2,133,133,0x86 },  // r72
{0x00aff5, 0x00031e, 72,2,133,133,0x86 },  // r73
{0x00b313, 0x000325, 74,2,133,133,0x86 },  // r74
{0x00b638, 0x000321, 76,1,132,133,0x86 },  // r75
{0x00b959, 0x00030e, 78,1,132,133,0x86 },  // r76
{0x00bc67, 0x000320, 80,1,132,133,0x86 },  // r77
{0x00bf87, 0x000322, 82,1,132,132,0x86 },  // r78
{0x00c2a9, 0x000327, 84,1,132,132,0x86 },  // r79
{0x00c5d0, 0x000329, 86,1,132,132,0x86 },  // r80
{0x00c8f9, 0x000326, 88,1,132,132,0x86 },  // r81
{0x00cc1f, 0x000328, 90,1,131,132,0x86 },  // r82
{0x00cf47, 0x00030d, 92,1,131,132,0x85 },  // r83
{0x00d254, 0x00030e, 94,1,131,131,0x85 },  // r84
{0x00d562, 0x00030b, 96,1,131,131,0x85 },  // r85
{0x00d86d, 0x000308, 98,1,131,131,0x85 },  // r86
{0x00db75, 0x000303, 100,1,131,131,0x85 },  // r87
{0x00de78, 0x0002fe, 102,1,130,130,0x85 },  // r88
{0x00e176, 0x0002fc, 104,1,130,130,0x85 },  // r89
{0x00e472, 0x000236, 106,1,130,130,0x84 },  // r90
};


void DrawSpeedNeedle( WORD x )
{
	//realize it with window0
	BITMAP	pBMP;
								
	//Printf("\n\r Winno=%x   x=%x\n", windowNo, x);
	pBMP.width=Speedneedlere[x].right-Speedneedlere[x].left;
	pBMP.height=Speedneedlere[x].bottom-Speedneedlere[x].top;
	pBMP.compression=Speedneedlere[x].rle_bits;
	pBMP.color_depth=0x88;
	pBMP.data_length=Speedneedlere[x].length;
	pBMP.bmpdata=Speedneedlere[x].start+spi_speedneedle_addr;

	User_Canvasspeed[0].Screen_X=Speedneedlere[x].left+Speed_OFFSET_X;
	User_Canvasspeed[0].Screen_Y=Speedneedlere[x].top+Speed_OFFSET_Y;
	User_Canvasspeed[0].width=Speedneedlere[x].right-Speedneedlere[x].left;
	User_Canvasspeed[0].height=Speedneedlere[x].bottom-Speedneedlere[x].top;
	TWLL_WaitDisplayBlank(1);
	TWLL_Canvas_Init(&User_Canvasspeed[0]);
		
	OSD_LoadBmp((const U8 *)&pBMP,User_Canvasspeed[0].Mem_X, User_Canvasspeed[0].Mem_Y,8 );


}

void DrawOilNeedle( WORD x )
{
	BITMAP	pBMP;
	
	//Printf("\n\r Winno=%x   x=%x\n", windowNo, x);
	pBMP.width=Oilneedlere[x].right-Oilneedlere[x].left;
	pBMP.height=Oilneedlere[x].bottom-Oilneedlere[x].top;
	pBMP.compression=Oilneedlere[x].rle_bits;
	pBMP.color_depth=0x88;
	pBMP.data_length=Oilneedlere[x].length;
	pBMP.bmpdata=Oilneedlere[x].start+spi_oilneedle_addr;

	User_Canvasspeed[1].Screen_X=Oilneedlere[x].left+Oil_OFFSET_X;
	User_Canvasspeed[1].Screen_Y=Oilneedlere[x].top+Oil_OFFSET_Y;
	User_Canvasspeed[1].width=Oilneedlere[x].right-Oilneedlere[x].left;
	User_Canvasspeed[1].height=Oilneedlere[x].bottom-Oilneedlere[x].top;
	TWLL_WaitDisplayBlank(1);
	TWLL_Canvas_Init(&User_Canvasspeed[1]);
		
	OSD_LoadBmp((const U8 *)&pBMP,User_Canvasspeed[1].Mem_X, User_Canvasspeed[1].Mem_Y,8 );
	

}


void SpeedoMeterDemo( void )
{
	WORD i;
	BYTE mode=0, current=0,direction=1,step=1, next;
	BYTE mode1=0, current1=0,direction1=1,step1=1, next1;
	BOOL ret,flag;
	CMDST touchcmd;
	OSD_ShowWindowBmp(0, 0);					// OFF the display
	OSD_ShowWindowBmp(1, 0);
	
	OSD_LoadLUT( 0, 8,(const U8 *)Speedmeter_0_LUT  );
	DrawSpeedNeedle(0);
	OSD_LoadLUT( 1, 8,(const U8 *)Speedmeter_0_LUT  );
	DrawOilNeedle(0);
	OSD_ShowWindowBmp(0, 1);					// OFF the display
	OSD_ShowWindowBmp(1, 1);
	
	
	while (1) {
	 				// speed meter
			if ( direction ) {			// acceleration
				next = current + step;
				if ( next > 180 ) {
					next = 180;
					direction = 0;		// change to decrease
				}
				DrawSpeedNeedle( next );
				current = next;
			}
			else {
				if ( current > step )
					next = current - step;
				else   {
					next = 0;
					direction = 1;		// change to decrease
				}
				DrawSpeedNeedle( next );
				current = next;
			}
			//Oil meter
			if ( direction1 ) {			// acceleration
				next1 = current1 + step1;
				if ( next1 > 90 ) {
					next1 = 90;
					direction1 = 0;		// change to decrease
				}
				DrawOilNeedle( next1 );
				current1 = next1;
			}
			else {
				if ( current1 > step1 )
					next1 = current1- step1;
				else   {
					next1 = 0;
					direction1 = 1;		// change to decrease
				}
				DrawOilNeedle( next1 );
				current1 = next1;
			}
			
		ret=CheckTSCCMD(&touchcmd);
		if(ret)
			{
				if(touchcmd.Cmdbuf[0]==0)
					flag=TRUE;
				if ( touchcmd.Cmdbuf[0]== 0 ) 
					{
						if (( touchcmd.Cmdbuf[1] > 700 ) && ( (touchcmd.Cmdbuf[2]&0x1fff)  >400 )) 
							{
				//				Printf("\nEnter Break\n");
								goto RET;
							}
					}
				if(flag&&((touchcmd.Cmdbuf[1]-touchcmd.Cmdbuf[3])>50)&&(touchcmd.Cmdbuf[1]>touchcmd.Cmdbuf[3]))     //moveup
				{	

					step++;
					
					if(step==4)
					{
						step1=2;
					}
					else if(step==6)
					{
						step1=3;
					}
					else if(step==8)
					{
						step1=4;
					}
					
					if(step>8)
					{
						step=8;
						step1=4;
					}
				//	Printf("\n cmdbuf[1]=%x,   %x  Step0=%bx\n", touchcmd.Cmdbuf[1],touchcmd.Cmdbuf[3],step);
					flag=FALSE;
				}
				else if(flag&&((touchcmd.Cmdbuf[3]-touchcmd.Cmdbuf[1])>50)&&(touchcmd.Cmdbuf[1]<touchcmd.Cmdbuf[3]))  //move down
				{
					step--;
					
					if(step==8)
					{
						step1=4;
					}
					else if(step==6)
					{
						step1=3;
					}
					else if(step==4)
					{
						step1=2;
					}
					
		    			if(step==0)
		    			{
						step=1;
						step1=1;
		    			}
				//	Printf("\n lll=%x,   %x  Step0=%bx\n", touchcmd.Cmdbuf[1],touchcmd.Cmdbuf[3], step);
					flag=FALSE;
					
				}
			}
		}
		RET:  
			//Printf("\n\r Exit Rose Demo\n");
			OSD_ShowWindowBmp(0, 0);					// OFF the display
			OSD_ShowWindowBmp(1, 0);
			OSD_ShowWindowBmp(2, 0);
	

}


